﻿using System.Collections.Generic;
using Firefly.Framework.Windows;
using Firefly.Framework.Windows.ContentReaders;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;

namespace Firefly.ContentPipeline.Windows
{
    [ContentTypeWriter]
    public class FontListContentWriter : ContentTypeWriter<FontCollection>
    {
        protected override void Write(ContentWriter output, FontCollection value)
        {
            WriteFontList(output, value);
        }

        public override string GetRuntimeReader(TargetPlatform targetPlatform)
        {
            return typeof(FontCollectionContentReader).AssemblyQualifiedName;
        }

        internal static void WriteFontList(ContentWriter output, FontCollection value)
        {
            output.Write(value.Count);
            foreach (KeyValuePair<string, Font> item in value)
            {
                output.Write(item.Key);
                output.WriteObject<Font>(item.Value);
            }
        }
    }
}
